xl2tpd: add support to set own hostname in proto handler
authorMartin Schiller <[email protected]>
Tue, 7 Oct 2025 05:35:51 +0000 (07:35 +0200)
committerFlorian Eckert <[email protected]>
Mon, 27 Oct 2025 12:02:45 +0000 (13:02 +0100)
This is needed if the peer only allows certain hostnames to connect.

Signed-off-by: Martin Schiller <[email protected]>
net/xl2tpd/files/l2tp.sh

index 294c3ddecc435c504c88e68a5725f3f8d1ab8e91..08c5fe5891b3d9e52c476b12eb92224d84df5b26 100644 (file)
@@ -17,6 +17,7 @@ proto_l2tp_init_config() {
        proto_config_add_int "mtu"
        proto_config_add_int "checkup_interval"
        proto_config_add_string "server"
+       proto_config_add_string "hostname"
        available=1
        no_device=1
        no_proto_task=1
@@ -26,9 +27,9 @@ proto_l2tp_init_config() {
 proto_l2tp_setup() {
        local interface="$1"
        local optfile="/tmp/l2tp/options.${interface}"
-       local ip serv_addr server host
+       local ip serv_addr server host hostname
 
-       json_get_var server server
+       json_get_vars server hostname
        host="${server%:*}"
        for ip in $(resolveip -t 5 "$host"); do
                ( proto_add_host_dependency "$interface" "$ip" )
@@ -41,6 +42,8 @@ proto_l2tp_setup() {
                exit 1
        }
 
+       hostname="${hostname:+hostname=$hostname}"
+
        # Start and wait for xl2tpd
        if [ ! -p /var/run/xl2tpd/l2tp-control -o -z "$(pidof xl2tpd)" ]; then
                /etc/init.d/xl2tpd restart
@@ -88,7 +91,7 @@ $mtu
 $pppd_options
 EOF
 
-       xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} || {
+       xl2tpd-control add-lac l2tp-${interface} pppoptfile=${optfile} lns=${server} ${hostname} || {
                echo "xl2tpd-control: Add l2tp-$interface failed" >&2
                proto_setup_failed "$interface"
                exit 1